//
//  OperateButton.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/4.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "OperateButton.h"

@implementation OperateButton

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.backgroundColor = [[UIColor colorWithRed:237.0f/255.0f green:34.0f/255.0f blue:59.0f/255.0f alpha:1.0f] CGColor];
        self.layer.cornerRadius = ScreenX375(22);
        self.alpha = 1;
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.titleLabel.font = Kfont(16);
        
        CALayer *shadowLayer = [[CALayer alloc] init];
        shadowLayer.frame = self.bounds;
        shadowLayer.shadowColor = [UIColor colorWithRed:237.0f/255.0f green:34.0f/255.0f blue:59.0f/255.0f alpha:0.3f].CGColor;
        shadowLayer.shadowOpacity = 1;
        shadowLayer.shadowOffset = CGSizeMake(0, 0);
        shadowLayer.shadowRadius = 3;
        CGFloat shadowSize = 1;
        CGRect shadowSpreadRect = CGRectMake(-shadowSize, -shadowSize, self.bounds.size.width+shadowSize*2, self.bounds.size.height+shadowSize*2);
        CGFloat shadowSpreadRadius =  self.layer.cornerRadius == 0 ? 0 : self.layer.cornerRadius+shadowSize;
        UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:shadowSpreadRect cornerRadius:shadowSpreadRadius];
        shadowLayer.shadowPath = shadowPath.CGPath;
        [self.layer addSublayer:shadowLayer];
    }
    return self;
}

@end

@implementation ThemeButton

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.backgroundColor = [[UIColor colorWithRed:237.0f/255.0f green:34.0f/255.0f blue:59.0f/255.0f alpha:1.0f] CGColor];
        self.layer.cornerRadius = ScreenX375(22);
        self.alpha = 1;
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.titleLabel.font = Kfont(16);
        
//        CALayer *shadowLayer = [[CALayer alloc] init];
//        shadowLayer.frame = self.bounds;
//        shadowLayer.shadowColor = [UIColor colorWithRed:237.0f/255.0f green:34.0f/255.0f blue:59.0f/255.0f alpha:0.3f].CGColor;
//        shadowLayer.shadowOpacity = 1;
//        shadowLayer.shadowOffset = CGSizeMake(0, 0);
//        shadowLayer.shadowRadius = 3;
//        CGFloat shadowSize = 1;
//        CGRect shadowSpreadRect = CGRectMake(-shadowSize, -shadowSize, self.bounds.size.width+shadowSize*2, self.bounds.size.height+shadowSize*2);
//        CGFloat shadowSpreadRadius =  self.layer.cornerRadius == 0 ? 0 : self.layer.cornerRadius+shadowSize;
//        UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:shadowSpreadRect cornerRadius:shadowSpreadRadius];
//        shadowLayer.shadowPath = shadowPath.CGPath;
//        [self.layer addSublayer:shadowLayer];
    }
    return self;
}

@end

